package Execute.MiniSQL;

/*
* 与用户交互的时候需要一个结构，用于返回操作结果
* */

public class SqlResult {
    String sqlFeedBack = "";
    Object[][] valueLines = null;

    public SqlResult(String sqlFeedBack, Object[][] valueLines){
        this.sqlFeedBack = sqlFeedBack;
        this.valueLines = valueLines;
    }

    public SqlResult() {

    }

    @Override public String toString(){
        //Add code
        if(valueLines == null){
            return sqlFeedBack;
        }else {
            String s = null;
            for (int i = 0; i < valueLines.length; i++) {
                for(int j = 0; j < valueLines[i].length; j++) {
                    s += valueLines[i][j];
                    if (j != valueLines[i].length-1) s += ", ";
                }
                s += "\n";
            }
            return sqlFeedBack + "\n" + s;
        }
    }

    public String getSqlFeedBack() {
        return this.sqlFeedBack;
    }
}
